from datetime import datetime

from pydantic import Field
from typing import Optional, Annotated, List

from ...base import BaseApiListOut, BaseSchema, BaseApiOut


class AbolishBase(BaseSchema):
    # brand_id: Optional[int] = Field(None, description='品牌编码')
    company_code: Optional[str] = Field(None, description='商户编码')
    company_name: Optional[str] = Field(None, description='商户名称')
    batch_sn: Optional[str] = Field(None, description='码批次')
    batch_num: Optional[int] = Field(None, description='码批次数')
    scope_status: Optional[int] = Field(None, description='作废范围 1 整批作废 2 部分作废')
    counts: Optional[int] = Field(None, description='作废码量')
    scope_type: Optional[int] = Field(None, description='作废码类型 1 刮刮码 2 防伪码')
    scope_file: Optional[str] = Field(None, description='部分作废文件')
    remarks: Optional[str] = Field(None, description='备注')


class AbolishCreate(AbolishBase):
    pass


class Abolish(AbolishBase):
    id: Optional[int] = Field(0, description='自增ID')

    status: Optional[int] = Field(None, description='状态 0 未开始 1 作废中 2 成功 3 取消 4 错误')
    error_reason: Optional[str] = Field(None, description='错误原因')

    created_at: Annotated[Optional[datetime], Optional[str]] = None
    updated_at: Annotated[Optional[datetime], Optional[str]] = None


class AbolishOut(BaseApiOut):
    data: Annotated[Abolish, None] = None


class AbolishListOut(BaseApiListOut):
    data: Annotated[List[Abolish], None] = None
